|
|
|
|
|
|
|
method for properties that reference objects). Regular Function methods enable clients of the class's instance to get a property value. A Sub method enables clients to set a property value. You were already exposed to these types of methods on Day 3, Fundamental Object-Oriented Design, but for the sake of convenience, the following section illustrates each in simple examples. |
|
|
|
|
|
|
|
|
Given a property EmployeeName, the following are viable options for property methods: |
|
|
|
|
|
|
|
|
'A function
Public Function getEmployeeName() As String
End Function |
|
|
|
|
|
|
|
|
'A sub
Public Sub setEmployeeName(argName As String)
End Function |
|
|
|
|
|
|
|
|
Public Property Get EmployeeName() As String
End Property |
|
|
|
|
|
|
|
|
Public Property Let EmployeeName(argNewValue As String)
End Property |
|
|
|
|
|
|
|
|
If you want to use the Set property method, given an Employee object, you would have the following: |
|
|
|
|
|
|
|
|
Public Property Set Employee(argObject As SomeClass)
End Property |
|
|
|
|
|
|
|
|
There's not much difference between the property Let and Set methods, other than that the one is for non-object data and the other is for object references. This has been a source of confusion for many developers. |
|
|
|
|
|
|
|
|
Understanding Three Key Concepts in Object-Oriented Programming |
|
|
|
|
|
|
|
|
A good grasp of fundamental object-oriented concepts takes time. Nevertheless, there are three essential elements of object-oriented programming with which you should soon become well acquainted. They are |
|
|
|
|
|